//
//  PhotodetailsViewController.m
//  Lovelife
//
//  Created by dllo on 15/4/21.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "PhotodetailsViewController.h"
#import "BigPhotoCell.h"
#import "UIImageView+WebCache.h"
#import "NightManager.h"
@interface PhotodetailsViewController ()<UICollectionViewDataSource, UICollectionViewDelegate>
@property(nonatomic, retain)UICollectionView *bigPhotoView;
@property (nonatomic, retain) UICollectionViewFlowLayout *bigPhotoFlow;
@end

@implementation PhotodetailsViewController
- (void)dealloc
{
    [_bigPhotoFlow release];
    [_photoBigArr release];
    [_bigPhotoView release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.bigPhotoFlow = [[UICollectionViewFlowLayout alloc]init];
    self.bigPhotoFlow.itemSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height);
    self.bigPhotoFlow.minimumLineSpacing = 0;
    self.bigPhotoFlow.minimumInteritemSpacing = 0;
    self.bigPhotoFlow.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    [_bigPhotoFlow release];

    self.bigPhotoView = [[UICollectionView alloc]initWithFrame:self.view.frame collectionViewLayout:self.bigPhotoFlow];
    self.bigPhotoView.delegate = self;
    self.bigPhotoView.dataSource = self;
    self.bigPhotoView.pagingEnabled = YES;
    self.bigPhotoView.contentOffset = CGPointMake(self.view.frame.size.width * self.pageNum, 0);
    [self.view addSubview:self.bigPhotoView];
    [_bigPhotoView release];
    [self.bigPhotoView registerClass:[BigPhotoCell class] forCellWithReuseIdentifier:@"reuse"];
    
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.photoBigArr.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    BigPhotoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];

    NSString *strUrl = self.photoBigArr[indexPath.row];
    [cell.myImageView sd_setImageWithURL:[NSURL URLWithString:strUrl] placeholderImage:[UIImage imageNamed:@"3.jpg"]];
//    cell.backgroundColor = [UIColor colorWithRed:indexPath.row * 10 / 255.0 green:indexPath.row * 10 / 255.0 blue:indexPath.row * 10 / 255.0 alpha:1];
//    NSLog(@"%@",strUrl);
   
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//- (void)setLightDayModel
//{
//    [NightManager setBackgroundColorWithView:self.bigPhotoView];
//}
//
//- (void)setNightDayModel
//{
//    [NightManager setBackgroundColorWithView:self.bigPhotoView];
//}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
